package com.awspaass.user.apps.syncwechataddress;

import java.util.List;
import java.util.Map;

import com.actionsoft.bpms.commons.database.ColumnMapRowMapper;
import com.actionsoft.bpms.util.DBSql;
import com.actionsoft.sdk.local.SDK;
import com.awspaas.user.apps.shhtaerospaceindustrial.util.CoreUtil;

public class SyncTool {
	public static void  mergerNewAccount(String role) {

		String queryUserInfoSql = "select a.USERID,a.DEPID,a.USERNAME,a.MOBILE,a.STATUS,b.DEPIDAWS from WECHAT_USER a,BO_INFO_WECHAT_AWS b where a.DEPID=b.IDWECHAT AND a.COMPANYID=b.CONMPANYIDWECHAT AND a.STATUS='0'";
		List<Map<String, Object>> userWechatList = DBSql.query(queryUserInfoSql, new ColumnMapRowMapper(),
				new Object[] {});
		System.out.println(userWechatList.size());
		for (int i = 0; i < userWechatList.size(); i++) {
			Map<String, Object> userWechat = userWechatList.get(i);
			String userIdWechat = CoreUtil.objToStr(userWechat.get("USERID"));
			String depIdWechat = CoreUtil.objToStr(userWechat.get("DEPID"));
			String userNameWechat = CoreUtil.objToStr(userWechat.get("USERNAME"));
			String MOBILE = CoreUtil.objToStr(userWechat.get("MOBILE"));
			String depIdAws = CoreUtil.objToStr(userWechat.get("DEPIDAWS"));
			System.out.println(userNameWechat);
			int c_re = SDK.getORGAPI().createUser(depIdAws, userIdWechat, userNameWechat, role, null, null, false, null,
					MOBILE, null, null, null, null, null, null, null, null, null, null, userIdWechat, null);
			String updateUserStatusSql = "UPDATE WECHAT_USER SET STATUS=1 WHERE USERID = '" + userIdWechat + "'";
			DBSql.update(updateUserStatusSql);
		}

	}
	
	
}
